Ext.define('AmpleHarvest.views.article.cAreaEast',
{
	extend			: 'Ext.panel.Panel',
	alias			: 'widget.ampleharvest-views-article-careaeast',
	requires		:
	[
			"AmpleHarvest.objects.cce.cCCE",
			"AmpleHarvest.objects.metadata.cMetaData"//,
//			"AmpleHarvest.objects.hierarchydata.cHierarchyData",
//			"AmpleHarvest.objects.tags.cPanel"
	],
	title			: 'Enhancement',
	width			: 300,
	collapsible		: true,
	resizable		: true,
	layoutActivate	: true,
	layout			: 'accordion',
	iconCls			: 'toolbar-article-enhancement',
	listeners		:
	{
		objectResponse	: function(object)
		{
			this.add(object);
			if (this.layoutActivate)
			{
				this.ahCaller.add(this);
				this.layoutActivate = false;
			}
		}
	},

	initComponent	: function()
	{
		var obj_This = this;
		
		this.m_obj_CCEWin = Ext.create("AmpleHarvest.objects.cce.cCCE",
				{
					m_str_id : this.m_str_id,
					ahCaller : this
				});
		
		this.m_obj_CCEWin = Ext.create("AmpleHarvest.objects.metadata.cMetaData",
				{
					m_str_id : this.m_str_id,
					ahCaller : this
				});
		
//		this.m_obj_TagWin = Ext.create("AmpleHarvest.objects.tags.cPanel",
//				{
//					m_str_id : this.m_str_id,
//					ahCaller : this
//				});

		this.callParent();
	},

	setActive		: function()
	{
		this.bool_HasData = false;
		this.items.each(function(obj_Data, int_Index, int_Total)
				{
					if (obj_Data.hasData())
					{
						this.bool_HasData = true;
						// found a panel to activate no need to continue
						return false;
					}
					else
					{
						obj_Data.collapse();
					}
				}, this);
		if (!this.bool_HasData)
		{
//			this.collapse();
		}
	},

	get_JsonObject	: function(JsonObject)
	{
		var panel_num = 0;
//		if (JsonObject.CCE)
//		{
//			this.m_obj_CCEWin = Ext
//					.create("AmpleHarvest.objects.cce.cCCE");
////			this.m_obj_CCEWin.add_JsonObject(JsonObject.CCE);
//			this.add(this.m_obj_CCEWin);
//			panel_num++;
//		}
//		if (JsonObject.metadata)
//		{
//			this.m_obj_MetaDataWin = Ext
//					.create("AmpleHarvest.objects.metadata.cMetaData");
//			this.m_obj_MetaDataWin.add_JsonObject(JsonObject.metadata);
//			this.add(this.m_obj_MetaDataWin);
//			panel_num++;
//		}
//		if (JsonObject.hierarchy)
//		{
//			this.m_obj_HierarchyDataWin = Ext
//					.create("AmpleHarvest.objects.hierarchydata.cHierarchyData");
//			this.m_obj_HierarchyDataWin.add_JsonObject(JsonObject.hierarchy);
//			this.add(this.m_obj_HierarchyDataWin);
//			panel_num++;
//		}
		if (panel_num)
		{

			this.setTitle(this.title + ' (' + panel_num + ')');
		}
		this.setActive();
	}
}
);
